using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameStateManagement;
using Microsoft.Xna.Framework;

namespace PiratesOfBermuda
{
    class MultiPlayersMenuScreen : MenuScreen
    {
        public MultiPlayersMenuScreen()
            : base(String.Empty)
        {
            IsPopup = true;

            MenuEntry hostMenuEntry = new MenuEntry("Host");
            MenuEntry clientMenuEntry = new MenuEntry("Client");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            hostMenuEntry.Selected += HostMenuEntrySelected;
            clientMenuEntry.Selected += ClientMenuEntrySelected;
            backMenuEntry.Selected += BackMenuEntrySelected;

            MenuEntries.Add(hostMenuEntry);
            MenuEntries.Add(clientMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }

        protected override void UpdateMenuEntryLocations()
        {
            base.UpdateMenuEntryLocations();

            foreach (var entry in MenuEntries)
            {
                var position = entry.Position;

                position.Y += 60;

                entry.Position = position;
            }
        }

        void BackMenuEntrySelected(object sender, EventArgs e)
        {
            ScreenManager.AddScreen(new MainMenuScreen());
            ExitScreen();
        }

        void HostMenuEntrySelected(object sender, EventArgs e)
        {
            ScreenManager.AddScreen(new HostGameScreen());
            ExitScreen();
        }

        void ClientMenuEntrySelected(object sender, EventArgs e)
        {
            ScreenManager.AddScreen(new ClientGameScreen());
            ExitScreen();
        }
    }
}
